package com.wyp168.leetcode;

/**
 * @ClassName HalvesAreAlikeSolution
 * @Title TODO
 * @Description TODO
 * @Author wyp168
 * @Date 2022/11/11 00:26
 */
public class HalvesAreAlikeSolution {
    public static void main(String[] args) {
        String s = "Uo";
        HalvesAreAlikeSolution solution = new HalvesAreAlikeSolution();
        System.out.println(solution.halvesAreAlike(s));
    }

    public boolean halvesAreAlike(String s) {
        int indexL = 0, indexR = s.length() - 1;
        int countL = 0, countR = 0;
        char[] charArr = {'a', 'e', 'i', 'o', 'u'};
        while (indexL <= indexR) {
            char charL = s.charAt(indexL);
            char charR = s.charAt(indexR);
            for(int i = 0; i < 5; i ++) {
                if (charL == charArr[i] || charL == charArr[i] - 32) {
                    countL ++;
                }
                if (charR == charArr[i] || charR == charArr[i] - 32) {
                    countR ++;
                }
            }
            indexL ++;
            indexR --;
        }
        return countL == countR;
    }
}
